//
//  ChooseDepartCell.m
//  Marketing
//
//  Created by Hanen 3G 01 on 16/5/18.
//  Copyright © 2016年 Hanen 3G 01. All rights reserved.
//

#import "ChooseDepartCell.h"
#import "UserModel.h"

@implementation ChooseDepartCell

+(CGFloat)cellHeight
{
    return 50.0f;
}
+ (instancetype)cellWithTableView:(UITableView *)tableview
{
    
    
    static  NSString *  const visitedCellId = @"visCellId";
    ChooseDepartCell * cell = [tableview dequeueReusableCellWithIdentifier:visitedCellId];
    if (!cell) {
        cell = [[ChooseDepartCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:visitedCellId];
        [cell addSubviews];
    }
    return cell;
}
- (void)addSubviews
{
    self.cellWidth = KSCreenW - 50.0f;
    self.personLogo = [[UIImageView alloc] initWithFrame:CGRectMake(10, 8, [ChooseDepartCell cellHeight] - 16, [ChooseDepartCell cellHeight] - 16)];
    self.personLogo.backgroundColor = NavBackColor;
    _personLogo.layer.cornerRadius = ([ChooseDepartCell cellHeight] - 20) / 2.0f;
    _personLogo.layer.masksToBounds = YES;
    [self.contentView addSubview:_personLogo];
    
    _nameLbl = [ViewTool getLabelWith:CGRectMake(_personLogo.maxX + 20, 0, 120, [ChooseDepartCell cellHeight]) WithTitle:@"" WithFontSize:16.0f WithTitleColor:blackFontColor WithTextAlignment:NSTextAlignmentLeft];
    [self.contentView addSubview:_nameLbl];
    
    self.selectedImage = [[UIImageView alloc] initWithFrame:CGRectMake(_cellWidth - 50,[ChooseDepartCell cellHeight] / 2.0f - 15 , 30, 30)];
    self.selectedImage.image = [UIImage imageNamed:@"HY_list_btn_checkbox_normal"];
    [self.contentView addSubview:self.selectedImage];
    
    UIView *lien = [ViewTool getLineViewWith:CGRectMake(_nameLbl.x, [ChooseDepartCell cellHeight] -1, _cellWidth - _nameLbl.x, 1) withBackgroudColor:grayLineColor];
    [self.contentView addSubview:lien];
}
- (void)setModel:(UserModel *)model
{
   
    
    _model = model;
    [self.personLogo sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",LoadImageUrl,model.logo]] placeholderImage:nil];
    
    self.nameLbl.text = model.name;
}
- (void)awakeFromNib {
    [super awakeFromNib];

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
